[Solved]

您所在的位置:网站首页 flutter webview scroll listener [Solved]

[Solved]

2023-08-04 19:31| 来源: 网络整理| 查看: 265

First Method :-

Make a full scrollable Widget contains WebView (with dynamic height) and other containers above and below it. all should scroll inside the parent Widget

be sure flutter package:webview_flutter: any are properly install.

1.create Future fxn

String hight; double webHight =400; //default some value Future funcThatMakesAsyncCall() async{ var result = await controller.evaluateJavascript('document.body.scrollHeight'); //here we call javascript for get browser data setState(() { hight = result; },);}

2.we use SingleChildScrollView scrollDirection: Axis.vertical,

3.Inside use Column

4.finally we use Conatiner

inside Container we use WebView

here Container Code

Container( height: webHight+20, child: WebView( initialUrl: widget.url, onPageFinished: (webhight)async{ await funcThatMakesAsyncCall(); setState((){ webHight= double.parse(hight); }); }, javascriptMode: JavascriptMode.unrestricted, onWebViewCreated: (WebViewController webViewController) { controller = webViewController; }, ), ),

second method :-

plugin vesion :> webview_flutter: ^3.0.4

Column( children: [ Container( height: Get.height * 0.1, color: Colors.amber, ), Expanded( // height: 200, child: WebView( gestureNavigationEnabled: true, gestureRecognizers: { Factory( () => EagerGestureRecognizer(), ), }, onWebViewCreated: (WebViewController webViewController) { bscontroller.webcontroller = webViewController; }, initialUrl: 'https://flutter.dev', ), ) ], ),

when i stuck another time than in same problem and try my old answer but this not work this time for me so, than i figure out another way

and this second answer to same problem



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3